<?php
	include("../include/init.php");//将配置文件全部加载进来
	include("../include/check_login.php");//登录

	$insert = new sql_class("article_cate");

	$artcate_id = isset($_GET['artcate_id']) ? $_GET['artcate_id'] : 0;
	if(!$artcate_id){
		show_msg("请重新选择","artcate_list.php");
		exit;
	}

	$artcate_one = $insert->select("artcate_id = $artcate_id")->getOne();

	if($_POST){
		
		$data = array(
					"artcate_name"=>$_POST['artcate_name'],
					"artcate_time"=>strtotime($_POST['artcate_time']),
				);
		if($_FILES['artcate_img']['size'] > 0 ){
			$path = DIR."/uploads/";
			$filename = uploads("artcate_img",1048576,$path);
			$data['artcate_img'] = "uploads/".$filename;
		}

		$where = "artcate_id = $artcate_id";
		$insert_id = $insert->update($data,$where);
		if($insert_id){
			show_msg("更新文章分类成功","artcate_list.php");
			exit;
		}else{
			show_msg("更新文章分类失败","artcate_edit.php?artcate_id = $artcate_id");
			exit;
		}
	}
	

	$smarty->assign("artcate_one",$artcate_one);
	$smarty->display("admin/artcate_edit.html");//连接index.html



?>